<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<link href="<c:url value='/css/easyui.css'/>" rel="stylesheet">
<link href="<c:url value='/css/icon.css'/>" rel="stylesheet">
<script src="<c:url value='/js/bootstrap.file-input.js'/>"></script>
<script src="<c:url value='/js/jquery.min.js'/>"></script>
<script type="text/javascript"
	src="<c:url value='/js/jquery.easyui.min.js'/>"></script>
<script src="<c:url value='/js/checkFile.js'/>"></script>
<script src="<c:url value='/js/method_component_lib.js'/>"></script>
<script type="text/javascript">
	function goback() {
		history.go(-1);
	}
</script>
<div class="page-header">
	<h3 style="margin-top: auto">编辑功能函数组件</h3>
</div>
<c:set var="muri" value="${fn:replace(item.uri,':', '/')}" />
<div class="row-fluid">
	<div>
		<form class="form-horizontal"
			action="<%=request.getContextPath()%>/${muri}/update"
			method="POST" enctype="multipart/form-data"
			onsubmit="return valid();">
			<div class="control-group" id="div_name">
				<label class="control-label">名称</label>
				<div class="controls">
					<input type="text" placeholder="名称" name="name" id="name"
						value="${item.name}"> <span class="help-inline"
						id="help_name">英文</span>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">版本</label>
				<div class="controls">
					<input type="text" placeholder="版本" name="version"
						value="${item.version}">
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">描述信息</label>
				<div class="controls">
					<textarea rows="3" class="input-xxlarge" placeholder="描述信息"
						id="description" name="description">${item.description}</textarea>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">实现接口</label>
				<div class="controls">
					<c:choose>
						<c:when test="${! empty item.cinterface}">
							<code>
								<c:out value="${item.cinterface.name}" />
							</code>
						</c:when>
						<c:otherwise>
							<code>
								<c:out value="无" />
							</code>
						</c:otherwise>
					</c:choose>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">依赖文件</label>
				<div id="depend_list"></div>
				<div class="controls">
					<button type="button" class="btn" id="btn_add_dependence"
						onclick="click_add_dependence()"><i class="icon-plus"></i>&nbsp;添加依赖文件（已上传）</button>
				</div>
			</div>
			<c:choose>
				<c:when test="${! empty item.implement}">
					<div class="control-group">
						<label class="control-label">实现代码</label>
						<div class="controls">
							<textarea rows="10" class="input-xxlarge" placeholder="实现代码"
								id="implement" name="implement">${item.implement}</textarea>
						</div>
					</div>
				</c:when>
				<c:otherwise>
					<div id="div_upload_file">
					<div class="control-group">
						<label class="control-label">提示:</label>
						<div class="controls">
							<p class="control-label" style="width:auto">上传文件大小的总和不能超过4M</p>
						</div>
					</div>
						<div class="control-group">
							<label class="control-label">头文件</label>

							<c:forEach items="${headerfile}" var="list" varStatus="s">
								<div class="controls">
									<span>${list.key}<span> <input type="hidden"
											id="head_file_old" name="head_file_old" value="${list.value}">
											<button style="margin-left: 50px; margin-bottom: 2px"
												type="button" class="btn" onclick="deltr(this)">删除</button>
								</div>
							</c:forEach>
							<div id="head_list"></div>
							<div class="controls">
								<button type="button" class="btn" id="btn_add_head_file"
									onclick="show_add_head_file()"><i class="icon-plus"></i>&nbsp;添加.h头文件</button>
							</div>
						</div>
					</div>

					<div class="control-group">
						<label class="control-label">源文件</label>
						<c:forEach items="${srcfile}" var="list" varStatus="s">
							<div class="controls">
								<span>${list.key}<span> <input type="hidden"
										id="src_file_old" name="src_file_old" value="${list.value}">
										<input type="hidden" id="param_name_temp"
										value="'
													+ fun_param_name
													+ '">
										<button style="margin-left: 50px; margin-bottom: 2px"
											type="button" class="btn" onclick="deltr(this)">删除</button>
							</div>

						</c:forEach>
						<div id="src_list"></div>
						<div class="controls">
							<button type="button" class="btn" id="btn_add_src_file"
								onclick="show_add_src_file()"><i class="icon-plus"></i>&nbsp;添加.c源文件</button>
						</div>
					</div>
				</c:otherwise>
			</c:choose>
			<div class="control-group">
				<div class="controls" style="float: center;">
					<button type="submit" class="btn" id="submit"><i class="icon-ok"></i>&nbsp;提交</button>
					<button type="button" class="btn" style="margin-left: 50px;" id="" onclick="goback()"><i class="icon-remove"></i>&nbsp;取消</button>
				</div>
			</div>
		</form>
	</div>
</div>
<!--/row-->
<div id="dependDlg" class="easyui-dialog" title="已上传文件列表"
	style="width: 800px; height: auto; padding: 10px" closed="true"
	data-options="iconCls: 'icon-search-dialog'">
	<div>
		<div class="input-append">
			<input style="width: 300px" type="text" id="search_name">
			<button class="btn" type="button" onclick="search_file_list()"><i class="icon-search"></i>&nbsp;检索</button>
		</div>
		<table class="table table-hover" id="file_list">
			<thead>
				<tr>
					<th>选择</th>
					<th>类型</th>
					<th>名称</th>
					<th>所属组件名称</th>
				</tr>
			</thead>
			<tbody>
			</tbody>
		</table>
	</div>
		<div id="dlg-buttons" style="float: right;">
			<a href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-ok-dialog" onclick="dlgOK()">确定</a> <a
				href="javascript:void(0)" class="easyui-linkbutton"
				iconCls="icon-cancel-dialog" onclick="dlgCancel()">取消</a>
		</div>
		<script type="text/javascript">
			$(function() {
				$('#dependDlg').dialog('close');
			});
			function dlgOK(){
				$('#dependDlg').dialog('close');
                select_files();
			}
			function dlgCancel(){
				$('#dependDlg').dialog('close');
                cancel_file_list();
			}
		</script>